﻿using System;

namespace IceDog.DNF.Program.Poker.Client.Cli
{
    /// <summary>
    /// 帮助类
    /// </summary>
    public static class Helper
    {
        /// <summary>
        /// 获取符合条件的输入
        /// </summary>
        /// <param name="tips">提示内容</param>
        /// <param name="conditionList">符合条件参数列表</param>
        /// <returns></returns>
        public static string GetRightInput(string tips, string[] conditionList)
        {
            var count = 0;
            Console.WriteLine(tips);
            while (true)
            {
                if (count != 0)
                {
                    Console.WriteLine("输入错误，请重新输入：");
                }
                var input = Console.ReadLine()?.ToLowerInvariant();
                foreach (string str in conditionList)
                {
                    if ((!string.IsNullOrEmpty(input)) && str.ToLowerInvariant().Equals(input))
                    {
                        return input;
                    }
                }
                count += 1;
            }
        }
    }
}
